package com.betterjr.modules.risk.loan.dubbo;

import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.betterjr.common.mapper.BeanMapper;
import com.betterjr.common.web.AjaxObject;
import com.betterjr.modules.risk.loan.ILoanProjectElcAgreementService;
import com.betterjr.modules.risk.loan.entity.LoanProjectElcAgreement;
import com.betterjr.modules.risk.loan.service.LoanProjectElcAgreementService;

@Service(interfaceClass = ILoanProjectElcAgreementService.class)
public class LoanProjectEclAgreementDubboService implements ILoanProjectElcAgreementService {

    @Autowired
    private LoanProjectElcAgreementService agreementService;

    /**
     * 新增电子合同
     * <p>Overriding Method of webSaveAddAgreement</p>  
     * <p>Description: </p> 
     * @param anMap
     * @return 
     * @see com.betterjr.modules.risk.loan.ILoanProjectElcAgreementService#webSaveAddAgreement(java.util.Map) 
     * @author xuyp
     * @date 2018年7月2日 上午9:50:33
     */

    @Override
    public String webSaveAddAgreement(Map<String, Object> anMap) {

        LoanProjectElcAgreement agreement = new LoanProjectElcAgreement();
        // BeanUtils.copyProperties(anMap, agreement, LoanProjectElcAgreement.class);
        BeanMapper.copy(anMap, agreement);
        return AjaxObject.newOk("新增成功", agreementService.saveAddAgreement(agreement)).toJson();
    }

    @Override
    public String webQueryElcAgreement(Long anLoanId, String anType) {

        return AjaxObject.newOk("查询成功", agreementService.queryElcAgreement(anLoanId, anType)).toJson();
    }

}
